package com.cxdr.awsips.distribute.pool;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

import com.cxdr.awsips.common.logger.LogFactory;

public class BaseQueue<E> {
	private static Logger logger = LogFactory.makeNewLogger(BaseQueue.class);
	private LinkedBlockingQueue<E> queue = new LinkedBlockingQueue<E>();
	private static final int TIME_OUT = 10;

	public boolean contains(E file) {
		return queue.contains(file);
	}

	public void add(E file) {
		queue.add(file);
	}

	public E take() {
		E eml = null;
		try {
//			 eml = queue.poll(TIME_OUT, TimeUnit.NANOSECONDS);
//			logger.info("take");
			eml = queue.take();
//			logger.info("take end:"+eml);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return eml;
	}
	public int size(){
		return queue.size();
	}
	public boolean isEmpty() {
		return queue.isEmpty();
	}
}
